<template>
  <div id="login-app">

    <video autoplay loop muted id="bgvid">
      <source src="../../assets/background-video.mp4" type="video/mp4" />
    </video>

    <el-form :model="loginFrom" status-icon :rules="rules" ref="loginFrom" label-width="100px" class="login-loginFrom">
      <h1>地球人类档案管理系统</h1>
      <div class="input">
                <el-form-item label="用户名" prop="username">
        <el-input type="text" v-model="loginFrom.username" autocomplete="off"></el-input> 
        <!-- autocomplete="off"表示是否自动补齐 -->
      </el-form-item>

      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="loginFrom.password" autocomplete="off"></el-input>
      </el-form-item>

  

      <el-form-item>
        <el-button type="primary" @click="submitForm('loginFrom')">提交</el-button>
        <el-button @click="resetForm('loginFrom')">重置</el-button>
      </el-form-item>
      </div>


    </el-form>
  </div>
</template>

  <script>
  export default {
    data() {

      var validateUsn = (rule, value, callback) => {
        //用户名正则，4到16位（字母，数字，下划线，减号）
        var uPattern = /^[a-zA-Z0-9_-]{3,16}$/;
        if(uPattern.test(value)){ //表示校验成功，则返回空
          callback()
        }else{ 
          callback('输入4到16位（字母，数字，下划线，减号）')
        }
      };
      var validatePsw = (rule, value, callback) => {
      if(!value){
        callback('密码不能为空')
      }else{
        callback()
      }
      };
      return {
        loginFrom: {
          username: '',
          password: '',
        },
        rules: {
          username: [
            { validator: validateUsn, trigger: 'blur' }
          ],
          password: [
            { validator: validatePsw, trigger: 'blur' }
          ],

        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) { //表示本地校验通过
            alert('Welcome!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style scoped lang="less">

source {
  min-width: 100%;
  min-height: 100%;
  height: auto;
  width: auto;
}

video {
  object-fit:cover;
  position: fixed;
  right: 0px;
  bottom: 0px;
  min-width: 100%;
  max-height: 100%;
  height: auto;
  width: auto;
  background-size: cover;
  // background-image: url('../../assets/背景.jpg');
  /*加滤镜*/
  /* filter: blur(15px); //背景模糊设置 */
  /*-webkit-filter: grayscale(100%);*/
  /*filter:grayscale(100%); //背景灰度设置*/
  z-index: -11;
}
 h1{
   color: green;
   text-align: center;
   margin-bottom: 10px;
 }
 .login-loginFrom{
   width: 400px;
   height: 485px;
   position: fixed;
  //  background: rgba(10,120,180,0.5) !important;
   right: 50px;
   bottom: -110px;
   box-sizing: border-box;
   & /deep/ .el-input__inner{
     width: 250px;
   }
   .input{
     margin-bottom: 150px;
   }
   
 }
</style>
